package com.yike.user.controller;

import com.yike.user.entity.AgentWithdrawalRecord;
import com.yike.user.service.AgentWithdrawalRecordService;
import lombok.extern.slf4j.Slf4j;
import com.yike.user.param.AgentWithdrawalRecordPageParam;
import com.yike.common.base.BaseController;
import com.yike.common.api.ApiResult;
import com.yike.common.pagination.Paging;
import com.yike.common.api.IdParam;
import com.yike.common.log.Module;
import com.yike.common.log.OperationLog;
import com.yike.common.enums.OperationLogType;
import com.yike.common.api.Add;
import com.yike.common.api.Update;
import org.springframework.validation.annotation.Validated;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 代理商提现记录表 控制器
 *
 * @author Sakura
 * @since 2024-09-23
 */
@Slf4j
@RestController
@RequestMapping("/agentWithdrawalRecord")
@Module("user")
@Api(value = "代理商提现记录API", tags = {"代理商提现记录管理"})
@ApiIgnore
public class AgentWithdrawalRecordController extends BaseController {

    @Autowired
    private AgentWithdrawalRecordService agentWithdrawalRecordService;

    /**
     * 添加代理商提现记录表
     */
    @PostMapping("/add")
    @OperationLog(name = "添加代理商提现记录表", type = OperationLogType.ADD)
    @ApiOperation(value = "添加代理商提现记录表", response = ApiResult.class)
    public ApiResult<Boolean> addAgentWithdrawalRecord(@Validated(Add.class) @RequestBody AgentWithdrawalRecord agentWithdrawalRecord) throws Exception {
        boolean flag = agentWithdrawalRecordService.saveAgentWithdrawalRecord(agentWithdrawalRecord);
        return ApiResult.result(flag);
    }

    /**
     * 修改代理商提现记录表
     */
    @PostMapping("/update")
    @OperationLog(name = "修改代理商提现记录表", type = OperationLogType.UPDATE)
    @ApiOperation(value = "修改代理商提现记录表", response = ApiResult.class)
    public ApiResult<Boolean> updateAgentWithdrawalRecord(@Validated(Update.class) @RequestBody AgentWithdrawalRecord agentWithdrawalRecord) throws Exception {
        boolean flag = agentWithdrawalRecordService.updateAgentWithdrawalRecord(agentWithdrawalRecord);
        return ApiResult.result(flag);
    }

    /**
     * 删除代理商提现记录表
     */
    @PostMapping("/delete/{id}")
    @OperationLog(name = "删除代理商提现记录表", type = OperationLogType.DELETE)
    @ApiOperation(value = "删除代理商提现记录表", response = ApiResult.class)
    public ApiResult<Boolean> deleteAgentWithdrawalRecord(@PathVariable("id") Long id) throws Exception {
        boolean flag = agentWithdrawalRecordService.deleteAgentWithdrawalRecord(id);
        return ApiResult.result(flag);
    }

    /**
     * 获取代理商提现记录表详情
     */
    @GetMapping("/info/{id}")
    //@OperationLog(name = "代理商提现记录表详情", type = OperationLogType.INFO)
    @ApiOperation(value = "代理商提现记录表详情", response = AgentWithdrawalRecord.class)
    public ApiResult<AgentWithdrawalRecord> getAgentWithdrawalRecord(@PathVariable("id") Long id) throws Exception {
        AgentWithdrawalRecord agentWithdrawalRecord = agentWithdrawalRecordService.getById(id);
        return ApiResult.ok(agentWithdrawalRecord);
    }

    /**
     * 代理商提现记录表分页列表
     */
    @PostMapping("/getPageList")
    //@OperationLog(name = "代理商提现记录表分页列表", type = OperationLogType.PAGE)
    @ApiOperation(value = "代理商提现记录表分页列表", response = AgentWithdrawalRecord.class)
    public ApiResult<Paging<AgentWithdrawalRecord>> getAgentWithdrawalRecordPageList(@Validated @RequestBody AgentWithdrawalRecordPageParam agentWithdrawalRecordPageParam) throws Exception {
        Paging<AgentWithdrawalRecord> paging = agentWithdrawalRecordService.getAgentWithdrawalRecordPageList(agentWithdrawalRecordPageParam);
        return ApiResult.ok(paging);
    }

}

